package com.goldstone.entity;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "CODES")
public class Code extends AuditableEntity {
	String code;
	String name;
	String descs;
	Code parent;
	List<Code> codes;
	
	public Code() {}
	public Code(String code, String name) {
		this.code = code;
		this.name = name;
	}
	
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getDescs() {
		return descs;
	}
	public void setDescs(String descs) {
		this.descs = descs;
	}
	
	@OneToMany(mappedBy = "parent", cascade = CascadeType.ALL)
	public List<Code> getCodes() {
		return codes;
	}
	public void setCodes(List<Code> codes) {
		this.codes = codes;
	}
	@ManyToOne
	@JoinColumn(name = "P_ID", insertable = false, updatable = false)
	public Code getParent() {
		return parent;
	}
	public void setParent(Code parent) {
		this.parent = parent;
	}
	
}
